<?php
if ($_REQUEST["odeslat_cena"]) {
            // přidání ip do databáze - tato IP provedla změnu
            $vysledek = MySQL_Query("SELECT * FROM ip WHERE ip like '$ip' AND kdo like '$kdo'");
            // pokud ip v databázi není => přidej
            if (mysql_num_rows($vysledek) == 0) {
                $sql = MySQL_Query("INSERT INTO ip (ip,kdy,kdo) VALUES('$ip','$kdy','$kdo')");
                // pokud ip v dtb je => přepiš
            } else {
                $sql = MySQL_Query("DELETE from ip WHERE kdo LIKE '$kdo' AND ip LIKE '$ip' LIMIT 1");
                $sql = MySQL_Query("INSERT INTO ip (ip,kdy,kdo) VALUES('$ip','$kdy','$kdo')");
            }
            $pecha = $_POST[pecha];
            $obr = $_POST[obr];
            $tank = $_POST[tank];
            $stihy = $_POST[stihy];
            $vrtule = $_POST[vrtule];
            $kasarny = $_POST[kasarny];

            $dotaz1 = MySQL_Query("UPDATE ceny SET pecha=$pecha WHERE kdo LIKE '$kdo'");
            $dotaz2 = MySQL_Query("UPDATE ceny SET obr=$obr WHERE kdo LIKE '$kdo'");
            $dotaz3 = MySQL_Query("UPDATE ceny SET tank=$tank WHERE kdo LIKE '$kdo'");
            $dotaz4 = MySQL_Query("UPDATE ceny SET stihy=$stihy WHERE kdo LIKE '$kdo'");
            $dotaz5 = MySQL_Query("UPDATE ceny SET vrtule=$vrtule WHERE kdo LIKE '$kdo'");
        } // IF REGUEST ODESLAT_CENA

        if ($_REQUEST["kasarny"]) {
            if ($_POST["kasarny"] == 'UPGRADE') {
                $kasarny = '200';
                $sql = MySQL_Query("UPDATE ceny SET kasarny=$kasarny WHERE kdo LIKE '$kdo'");
            }
            if ($_POST["kasarny"] == 'DOWNGRADE') {
                $kasarny = '100';
                $sql = MySQL_Query("UPDATE ceny SET kasarny=$kasarny WHERE kdo LIKE '$kdo'");
            }
        }
        if ($_REQUEST["jidelny"]) {
            if ($_POST["jidelny"] == 'UPGRADE') {
                $jidelny = '150';
                $sql = MySQL_Query("UPDATE ceny SET jidelny=$jidelny WHERE kdo LIKE '$kdo'");
            }
            if ($_POST["jidelny"] == 'DOWNGRADE') {
                $jidelny = '100';
                $sql = MySQL_Query("UPDATE ceny SET jidelny=$jidelny WHERE kdo LIKE '$kdo'");
            }
        }
        if ($_REQUEST["rafinerie"]) {
            if ($_POST["rafinerie"] == 'UPGRADE') {
                $rafinerie = '3200';
                $sql = MySQL_Query("UPDATE ceny SET rafinerie=$rafinerie WHERE kdo LIKE '$kdo'");
            }
            if ($_POST["rafinerie"] == 'DOWNGRADE') {
                $rafinerie = '2000';
                $sql = MySQL_Query("UPDATE ceny SET rafinerie=$rafinerie WHERE kdo LIKE '$kdo'");
            }
        }
        $vysledek = MySQL_Query("SELECT * FROM ceny WHERE kdo LIKE '$kdo'");
        while ($zaznam = MySQL_Fetch_Array($vysledek)) {
            $pecha = $zaznam['pecha'];
            $obr = $zaznam['obr'];
            $tank = $zaznam['tank'];
            $stihy = $zaznam['stihy'];
            $vrtule = $zaznam['vrtule'];
            $kasarny = $zaznam['kasarny'];
            $jidelny = $zaznam['jidelny'];
            $rafinerie = $zaznam['rafinerie'];
        } // WHILE
        if ($kasarny == '100') {
            $kasarny = '<td class="cervena">NEDOKONČENO';
            $kasarny2 = 'UPGRADE';
        }
        if ($kasarny == '200') {
            $kasarny = '<td class="zelena">DOKONČENO';
            $kasarny2 = 'DOWNGRADE';
        }
        if ($jidelny == '100') {
            $jidelny = '<td class="cervena">NEDOKONČENO';
            $jidelny2 = 'UPGRADE';
        }
        if ($jidelny == '150') {
            $jidelny = '<td class="zelena">DOKONČENO';
            $jidelny2 = 'DOWNGRADE';
        }
        if ($rafinerie == '2000') {
            $rafinerie = '<td class="cervena">NEDOKONČENO';
            $rafinerie2 = 'UPGRADE';
        }
        if ($rafinerie == '3200') {
            $rafinerie = '<td class="zelena">DOKONČENO';
            $rafinerie2 = 'DOWNGRADE';
        }
?>
        <table width="60%" height="259" border="0">
            <form name="form1" method="post" action="?k=<?php echo $kdo . "&kod=" . $kod . "&vyber=" . $vyber; ?>">
                <tr class="lichy">
                    <td>Pěchota:</td>
                    <td><input name="pecha" type="text" value="<?php echo $pecha; ?>"> Kč</td>
                </tr>
                <tr class="sudy">
                    <td>Obrněný jednotky:</td>
                    <td><input name="obr" type="text" value="<?php echo $obr; ?>"> Kč</td>
                </tr>
                <tr class="lichy">
                    <td>Tanky:</td>
                    <td><input name="tank" type="text" value="<?php echo $tank; ?>"> Kč</td>
                </tr>
                <tr class="sudy">
                    <td>Stihy:</td>
                    <td><input name="stihy" type="text" value="<?php echo $stihy; ?>"> Kč</td>
                </tr>
                <tr class="lichy">
                    <td >Vrtule:</td>
                    <td><input name="vrtule" type="text" value="<?php echo $vrtule; ?>"> Kč</td>
                </tr>
                <tr class="sudy">
                    <td>Upgrade kasáren:</td>
<?php echo $kasarny; ?>  <input name="kasarny" type="submit" value="<?php echo $kasarny2; ?>"></td>
                </tr>
                <tr class="lichy">
                    <td>Upgrade jídelen:</td>
<?php echo $jidelny; ?>  <input name="jidelny" type="submit" value="<?php echo $jidelny2; ?>"></td>
                </tr>
                <tr class="sudy">
                    <td>Upgrade rafinerii:</td>
            <?php echo $rafinerie; ?>  <input name="rafinerie" type="submit" value="<?php echo $rafinerie2; ?>"></td>
                    </tr>
                    <tr class="lichy">
                        <td colspan="2">
                            <label>
                                <input type="submit" name="odeslat_cena" id="odeslat_cena" value="Odeslat">
                            </label>
                </form></td>
                </tr>
            </table>
            <br /><br /><br />
            <table width="448" border="1">
                <tr class="lichy">
                    <th colspan="2">Tyto IP provedly změny:</th>
                </tr>
        <?php
                $vysledek = MySQL_Query("SELECT * FROM ip WHERE kdo LIKE '$kdo' ORDER BY id");
                while ($zaznam = MySQL_Fetch_Array($vysledek)) {
        ?>
                        <tr class="sudy">
                            <td><?php echo $zaznam['ip'] ?></td>
                            <td><?php echo $zaznam['kdy'] ?></td>
        <?php // if (kod) { echo '<td><form action="#" name="smaz_ip" type="POST"><input type="hidden" name="ip" value=".$zaznam[\'ip\']."><input type="submit" name="smaz_id" value="Smaž id"></form></td>'; } ?>
                        </tr>
        <?php } // WHILE ?>
                </table>